#!/bin/bash

# Test partially zeroed data

. ./common

for i in `seq 0 5`; do
    _start_sheep $i
done

_wait_for_sheep 6

_cluster_format -c 6

_vdi_create test 4M

# Create a 28 KB file.  The first 12 KB (3 blocks) is filled with zero,
# next 4 KB is filled with one, and the rest is filled with zero.
DATA_FILE="$STORE/data"
rm -f $DATA_FILE
dd if=<(_one) of=$DATA_FILE bs=4k seek=3 count=1 2> /dev/null
truncate $DATA_FILE -s 28k

for skip in 0 1 2 3; do
    for offset in 0 512; do
	for length in $((4 * 4096)) $((4 * 4096 - 512)); do
	    dd if=$DATA_FILE bs=4k skip=$skip count=4 2> /dev/null \
		| $DOG vdi write test $offset $length

	    $DOG vdi read test $offset $length | hexdump -C
	done
    done
done
